package code.part02_objectOriented;


/**
 * @author: ZJT
 * @Time: 2021/7/13
 * @Description: 代码块
 */
public class P12_CodeBlock {


    int a;
    int b;

    static {
        System.out.println("静态代码块");
    }

    {
        System.out.println("构造代码块");
    }

    public P12_CodeBlock() {
        System.out.println("无参构造方法");
    }

    public P12_CodeBlock(int a) {
        System.out.println("单参构造方法");
        this.a = a;
    }

    public P12_CodeBlock(int a, int b) {
        this(a);
        System.out.println("双参构造方法");
        this.b = b;
//        this(a);//Call to 'this()' must be first statement in constructor body
    }


    public void run() {
        System.out.println("run");
        {
            System.out.println("普通代码块");
        }
    }


    public static void main(String[] args) {
        P12_CodeBlock codeBlock = new P12_CodeBlock(1, 2);
        codeBlock.run();
        {
            System.out.println("main");
        }
        new P12_CodeBlock(1);
    }
}
